//
//  WQCAuthViewController.m
//  renxinghuan
//
//  Created by 王晓民 on 2018/4/13.
//  Copyright © 2018年 吴清翠. All rights reserved.
//

#import "WQCAuthViewController.h"
#import "configuration.h"
@interface WQCAuthViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView  *tableView;
@property (nonatomic,strong)NSMutableArray *dataArray;
@property (nonatomic,strong)NSArray *titArr;
@end



@implementation WQCAuthViewController

-(NSMutableArray *)dataArray
{
    if (!_dataArray) {
        _dataArray=[[NSMutableArray alloc]init];
    }
    return _dataArray;
}
-(NSArray *)titArr
{
    if (!_titArr) {
        _titArr= @[@"真实姓名",@"身份证号",@"签发机关",@"有效期限",@"绑定储蓄卡"];
    }
    return _titArr;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = WYCGlobalBg;
    self.navigationItem.title = @"实名认证";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self.navigationController.navigationBar setBarTintColor:wycMain];
    [self loadZhengmian];
    UIView  *bgiew = [MyUIClass makeUIViewWithFram:CGRectMake(0, 0, ScreenWidth, 200) andBackColor:wycMain];
    [self.view addSubview:bgiew];
    UIImageView  *shiming = [MyUIClass makeUIImageViewWithFrame:CGRectMake(ScreenWidth/2-45, 80, 90, 60) andImage:@"auth"];
    [bgiew addSubview:shiming];
    UIImageView  *shiming1 = [MyUIClass makeUIImageViewWithFrame:CGRectMake(shiming.width-30, 40, 27, 27) andImage:@"renzheng"];
    [shiming addSubview:shiming1];
    
    UILabel  *smLb = [MyUIClass makeUILabelWithFrame:CGRectMake(0, 0, 0, 0) andBackColor:[UIColor clearColor] andText:@"" andTextColor:[UIColor whiteColor] andFont:[UIFont systemFontOfSize:15] andAlignment:NSTextAlignmentCenter];
    [bgiew addSubview:smLb];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, bgiew.frame.size.height+bgiew.frame.origin.y, ScreenWidth, 300) style:UITableViewStylePlain];
    self.tableView.backgroundColor = WYCGlobalBg;
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.scrollEnabled = YES;
    [self.view addSubview:self.tableView];
    
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"123"];
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.dataArray.count;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 50;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    tableView.tableFooterView = [[UIView alloc] init];
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"123"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"123"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
   
    
    UILabel  *titLb = [MyUIClass makeUILabelWithFrame:CGRectMake(10, 15, 120, 20) andBackColor:[UIColor clearColor] andText:[self.titArr objectAtIndex:indexPath.row] andTextColor:[UIColor blackColor] andFont:[UIFont systemFontOfSize:14] andAlignment:NSTextAlignmentLeft];
    [cell.contentView addSubview:titLb];
    
    UILabel * _name = [MyUIClass makeUILabelWithFrame:CGRectMake(100, 15, 250, 20) andBackColor:[UIColor clearColor] andText:@"" andTextColor:[UIColor blackColor] andFont:[UIFont systemFontOfSize:14] andAlignment:NSTextAlignmentLeft];
    [cell.contentView addSubview:_name];
    _name.text = self.dataArray[indexPath.row];

    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)loadZhengmian
{
    //图片压缩
    [HttpTool POST:getIdDetail params:nil success:^(NSURLSessionDataTask *task, id responseObject)
     {
         if ([[responseObject objectForKey:@"code"] intValue] == 0)
         {
             NSLog(@"已认证%@",responseObject);
             NSDictionary * dict = [responseObject objectForKey:@"result"];
            //身份证号
             [self.dataArray addObject: [dict objectForKey:@"name"]];
             [self.dataArray addObject: [dict objectForKey:@"num"]];
             [self.dataArray addObject: [dict objectForKey:@"issue"]];
             [self.dataArray addObject: [NSString stringWithFormat:@"%@-%@",[dict objectForKey:@"startDate"],[dict objectForKey:@"endDate"]]];
             [self.dataArray addObject: [dict objectForKey:@"cardNumber"]];

             [self.tableView reloadData];
         }else{
             
             [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
         }
     } fail:^(NSURLSessionDataTask *task, NSError *error)
     {
         [SVProgressHUD showImage:[UIImage imageNamed:@""] status:Failed];
     }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
